import 'package:factoryside/bean/add_order_entity.dart';

addOrderEntityFromJson(AddOrderEntity data, Map<String, dynamic> json) {
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['phone'] != null) {
		data.phone = json['phone'].toString();
	}
	if (json['sparephone'] != null) {
		data.sparephone = json['sparephone'].toString();
	}
	if (json['city'] != null) {
		data.city = json['city'].toString();
	}
	if (json['addstr'] != null) {
		data.addstr = json['addstr'].toString();
	}
	if (json['servicetype'] != null) {
		data.servicetype = json['servicetype'] is String
				? int.tryParse(json['servicetype'])
				: json['servicetype'].toInt();
	}
	if (json['guaranteetype'] != null) {
		data.guaranteetype = json['guaranteetype'] is String
				? int.tryParse(json['guaranteetype'])
				: json['guaranteetype'].toInt();
	}
	if (json['prods'] != null) {
		data.prods = new List<AddOrderProd>();
		(json['prods'] as List).forEach((v) {
			data.prods.add(new AddOrderProd().fromJson(v));
		});
	}
	if (json['backParts'] != null) {
		data.backParts = json['backParts'] is String
				? int.tryParse(json['backParts'])
				: json['backParts'].toInt();
	}
	if (json['backAddress'] != null) {
		data.backAddress = json['backAddress'] is String
				? int.tryParse(json['backAddress'])
				: json['backAddress'].toInt();
	}
	if (json['postpaytype'] != null) {
		data.postpaytype = json['postpaytype'] is String
				? int.tryParse(json['postpaytype'])
				: json['postpaytype'].toInt();
	}
	if (json['ThirdPartyOrderNumber'] != null) {
		data.thirdPartyOrderNumber = json['ThirdPartyOrderNumber'].toString();
	}
	return data;
}

Map<String, dynamic> addOrderEntityToJson(AddOrderEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['name'] = entity.name;
	data['phone'] = entity.phone;
	data['sparephone'] = entity.sparephone;
	data['city'] = entity.city;
	data['addstr'] = entity.addstr;
	data['servicetype'] = entity.servicetype;
	data['guaranteetype'] = entity.guaranteetype;
	if (entity.prods != null) {
		data['prods'] =  entity.prods.map((v) => v.toJson()).toList();
	}
	data['backParts'] = entity.backParts;
	data['backAddress'] = entity.backAddress;
	data['postpaytype'] = entity.postpaytype;
	data['ThirdPartyOrderNumber'] = entity.thirdPartyOrderNumber;
	return data;
}

addOrderProdFromJson(AddOrderProd data, Map<String, dynamic> json) {
	if (json['BuyingProductsTime'] != null) {
		data.buyingProductsTime = json['BuyingProductsTime'].toString();
	}
	if (json['FactoryBarCode'] != null) {
		data.factoryBarCode = json['FactoryBarCode'].toString();
	}
	if (json['prodExpressNo'] != null) {
		data.prodExpressNo = json['prodExpressNo'].toString();
	}
	if (json['subCategoryID'] != null) {
		data.subCategoryID = json['subCategoryID'] is String
				? int.tryParse(json['subCategoryID'])
				: json['subCategoryID'].toInt();
	}
	if (json['specifications'] != null) {
		data.specifications = json['specifications'] is String
				? int.tryParse(json['specifications'])
				: json['specifications'].toInt();
	}
	if (json['factoryBrandname'] != null) {
		data.factoryBrandname = json['factoryBrandname'] is String
				? int.tryParse(json['factoryBrandname'])
				: json['factoryBrandname'].toInt();
	}
	if (json['prodModel'] != null) {
		data.prodModel = json['prodModel'] is String
				? int.tryParse(json['prodModel'])
				: json['prodModel'].toInt();
	}
	if (json['Num'] != null) {
		data.num = json['Num'] is String
				? int.tryParse(json['Num'])
				: json['Num'].toInt();
	}
	if (json['ExpressNo'] != null) {
		data.expressNo = json['ExpressNo'].toString();
	}
	if (json['bak'] != null) {
		data.bak = json['bak'].toString();
	}
	if (json['partsVal'] != null) {
		data.partsVal = new List<AddOrderProdsPartsVal>();
		(json['partsVal'] as List).forEach((v) {
			data.partsVal.add(new AddOrderProdsPartsVal().fromJson(v));
		});
	}
	return data;
}

Map<String, dynamic> addOrderProdToJson(AddOrderProd entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['BuyingProductsTime'] = entity.buyingProductsTime;
	data['FactoryBarCode'] = entity.factoryBarCode;
	data['prodExpressNo'] = entity.prodExpressNo;
	data['subCategoryID'] = entity.subCategoryID;
	data['specifications'] = entity.specifications;
	data['factoryBrandname'] = entity.factoryBrandname;
	data['prodModel'] = entity.prodModel;
	data['Num'] = entity.num;
	data['ExpressNo'] = entity.expressNo;
	data['bak'] = entity.bak;
	if (entity.partsVal != null) {
		data['partsVal'] =  entity.partsVal.map((v) => v.toJson()).toList();
	}
	return data;
}

addOrderProdsPartsValFromJson(AddOrderProdsPartsVal data, Map<String, dynamic> json) {
	if (json['value'] != null) {
		data.value = json['value'] is String
				? int.tryParse(json['value'])
				: json['value'].toInt();
	}
	return data;
}

Map<String, dynamic> addOrderProdsPartsValToJson(AddOrderProdsPartsVal entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['value'] = entity.value;
	return data;
}